<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script>
      function Person(naem, age, gender) {
        this.name = name;
        this.age = age;
        this.gender = gender;
      }
      var per = new Person("孙悟空", 18, "男");
      // 当我们直接在页面中打印一个对象时，事件上是输出的对象的toString()方法的返回值
      // 如果我们希望在输出对象时不输出[object Object],可以为对象添加一个toString()方法

      per.toString = function () {
        return "我是一个Person";
      };
      var result = per.toString();
      console.log("result=" + result);
    </script>
  </head>
  <body></body>
</html>
